package org.example.dao;

import org.example.pojo.Book;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;


/**
 * @author TonySong
 * @date 2024/5/14 0014
 * @time 16:05
 */
public interface BookDao extends JpaRepository<Book, Long> {
    @Query("update Book b set b.amount = b.amount - 1 where b.id = ?1")
    //以上的语句是HQL
//    @Query(value = "update t_book set amount = amount - 1 where id = ?1"
//            ,nativeQuery = true)
    @Modifying
    //以上的sql是本地（原生）sql
    void updatpAmount(Long bid);
}
